<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title>紫色鹭</title>
    <link rel="stylesheet" href="../css/common.css">
    <link rel="stylesheet" href="../css/style.css">
</head>
<body>
<div id="header_01_html">
    <iframe id="header_01" src="head_01.html" frameborder="0"></iframe>
</div>
<div class="register container">
    <div class="logo"><img src="../img/logo_01.png" alt=""></div>
    <div class="test-phone">验证手机号</div>
    <div class="form">
        <ul>
            <li>
                <span class="label">手机号</span><input type="text" id="phone">
            </li>
            <li>
                <span class="label">验证码</span><input type="text" class="yzm" id="yzm"><button class="code" id="btnVerify">获取验证码</button>
            </li>
            <li>
                <span class="label">设置密码</span><input type="password" id="password">
            </li>
            <li>
                <span class="label">确认密码</span><input type="password" id="re_password">
            </li>
            <li>
                <div class="submit">完成</div>
            </li>
        </ul>
    </div>
</div>
</body>
<script src="../js/config.js"></script>
<script>
    var yzm_code;
    var rexg = /^1\d{10}$/;
    var wait=60;//时间  
    var t;//计时器  
    function time(){
        if (wait == 0) {
            $('#btnVerify').removeAttr('disabled');
            $('#btnVerify').text("获取验证码");
            wait = 60;
            stopTime();
        }else{
            $('#btnVerify').attr('disabled','disabled');
            $('#btnVerify').text("重新发送(" + wait + "s)");
            wait--;
            t=setTimeout(function(){
                time();
            },1000)
        }
    }
    function stopTime(){
        clearTimeout(t);
    }

    $("#btnVerify").click(function () {
        var phone = $("#phone").val();
        if(!phone){
            layer.msg("请输入手机号");
            return
        }
        if(!rexg.test(phone)){
            layer.msg("请输入正确的手机号");
            return
        }
        get_ajax("/web/auth/getcode",{phone:phone,type:1},function (data) {
            time();
            yzm_code = data;
        })
    })

    $(".submit").click(function () {
        var yzm = $("#yzm").val();
        var phone = $("#phone").val();
        var password = $("#password").val();
        var re_password = $("#re_password").val();
        if(!phone){
            layer.msg("请输入手机号");
            return
        }
        if(!yzm_code){
            layer.msg("请发送验证码");return
        }
        if(!password){
            layer.msg("请输入密码");
            return
        }
        if(!re_password){
            layer.msg("请重复密码");
            return
        }
        get_ajax("/web/auth/resetpassword",{phone:phone,code:yzm,newpassword:password},function (data) {
            location.href = "set_pswd_succ.html";
        })
    });

</script>
</html>